import { http } from "@/utils/http";
import type {
  PageVoSubsidiaryAccountListVo,
  ProjectSubsidiaryAccountAdd
} from "@/api/models";
import type { listQuery } from "@/api/projectChronologicalLedger";
import type { SubsidiarySplitCmd } from "@/api/models";

export function list(request: listQuery) {
  return http.get<PageVoSubsidiaryAccountListVo>(
    "/project/subsidiary-account",
    {
      params: request
    }
  );
}
export function preview(projectId: string, year: string) {
  return http.get<string>("/project/subsidiary-account/preview", {
    params: { projectId, year }
  });
}
export function allProjectDl(projectIds: string[], year: string) {
  let params = projectIds.map(pid => `projectId=${pid}`);
  params.push("year=" + year);
  return http.download("/project/subsidiary-account/all?" + params.join("&"));
}
export function split(subsidiarySplitCmd: SubsidiarySplitCmd) {
  return http.post<string>("/project/expense/split", {
    data: subsidiarySplitCmd
  });
}
export function add(expenseAddCmd: ProjectSubsidiaryAccountAdd) {
  return http.post<string>("/project/subsidiary-account/add", {
    data: expenseAddCmd
  });
}
